UniformReal ================= 生成服从均匀分布的随机数序列,输出范围为 :math:`[0, 1)`。 .. math:: output_i \sim \mathcal{U}(0, 1) 输入: - **length** - 输出数据长度。 - **seed** - 随机数种子 1。 - **seed2** - 随机数种子 2。 - **core_mask(int, 可选)** - 核掩码(仅适用于共享存储版本)。 输出: - **output** - 生成的随机数结果地址。 支持平台: ``FT78NE`` ``MT7004`` .. note:: - FT78NE 支持 fp32 - MT7004 支持 fp32, fp16 - 随机数生成基于输入种子 `seed` 与 `seed2`,相同的种子对应确定性输出。 **共享存储版本:** .. c:function:: void fp_uniform_real_s(float* output, int length, int seed, int seed2, int core_mask) .. c:function:: void hp_uniform_real_s(half* output, int length, int seed, int seed2, int core_mask) **C 调用示例:** .. code-block:: c :linenos: :emphasize-lines: 10 // FT78NE 示例 #include int main(int argc, char* argv[]) { float *output = (float *)0xA0000000; // output 在 DDR 空间 int length = 1024; int seed = 1234; int seed2 = 5678; int core_mask = 0xff; fp_uniform_real_s(output, length, seed, seed2, core_mask); return 0; } **私有存储版本:** .. c:function:: void fp_uniform_real_p(float* output, int length, int seed, int seed2) .. c:function:: void hp_uniform_real_p(half* output, int length, int seed, int seed2) **C 调用示例:** .. code-block:: c :linenos: :emphasize-lines: 9 // MT7004 示例 #include int main(int argc, char* argv[]) { float *output = (float *)0x10010000; int length = 1024; int seed = 1234; int seed2 = 5678; fp_uniform_real_p(output, length, seed, seed2); return 0; }